package Test01;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
 
public class Test3 {  
 
public static void main(String[] srg) {  
 
   String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver";   //加载JDBC驱动
 
   String dbURL = "jdbc:sqlserver://localhost:1433;DatabaseName=TEST";   //连接数据库和服务器
 
   String userName = "poppyyjn";   //用户名
 
   String userPwd = "123456";   //密码
 
   Connection dbConn;  
   String sql = "exec proc_person ?";
 
   try {  
 
   Class.forName(driverName);  
 
   dbConn = DriverManager.getConnection(dbURL, userName, userPwd); 
   
   PreparedStatement pstmt = dbConn.prepareStatement(sql);
   pstmt.setInt(1,1);
   ResultSet rs = pstmt.executeQuery();
   if(rs.next()) {
	   System.out.println(rs.getString(3));
   }
 
   System.out.println("Connection Successful!");   //连接成功
 
   } catch (Exception e) {  
 
   e.printStackTrace();  
 
   }  
 
}  
 
} 